<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>批改作业</title>
    <link href="bootstrap-4.6.1-dist/css/bootstrap.css"
          rel="stylesheet" type="text/css">
    <style>
        .dropdown{
            margin-bottom: -20px;
        }
        .dropdown:hover{
            margin: 0px;
        }
        .show{
            /*display: block;*/
            overflow: hidden;
            visibility: hidden;
            max-height: 0px;
            transform: scaleY(0);
        }
        .dropdown:hover .show{
            visibility: visible;
            overflow: hidden;
            transition: transform 0.2s;
            max-height: 999999px;
            transform: scaleY(1);
        }
        .userPortrait {
            width: 40px;
            height: 40px;
            border: 1px solid red;
            border-radius: 50%;
            overflow: hidden;
            margin: 0 auto;
            /*margin-top: 100px;*/
        }
        .userPortrait img {
            display: block;
            width: 100%;
            height:100%;
            border: 1px solid green;
        }
        .menu {
            width: 300%;
            float: left;
            padding: 15px;
            border: 1px solid black;
            margin-left: -16px;
        }
        .bt {
            position:fixed;
            display: inline-block;
            padding: 10px 20px;
            font-size: 18px;
            cursor: pointer;
            text-align: center;
            text-decoration: none;
            outline: none;
            color: #fff;
            background-color:dodgerblue;
            border: none;
            border-radius: 10px;
            box-shadow: 0 4px #999;
            right:4%;
        }

        .bt:hover {background-color:dodgerblue}

        .bt:active {
            background-color:dodgerblue;
            box-shadow: 0 5px #666;
            transform: translateY(4px);
        }
        .zt{
            size:14px;
            font-family: "黑体", "Courier New", monospace;
        }
    </style>
</head>
<body>
<!--眉头-->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
    <a class="navbar-brand col-1 text-center" href="index.html">爱思教育</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link active" href="#">张老师,您好,请批改作业!</a>
            </li>
            <li class="nav-item active dropdown">
                <a class="nav-link " href="teacherHome.html" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                    主页
                </a>
            </li>
            <li class="nav-item active">
                <a class="nav-link " href="teacherReleaseHomework.html" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                    发布作业
                </a>
            </li>
            </li>
        </ul>
    </div>
    <div class="userPortrait active dropdown">
        <a href="userInformation.html"><img src="img/defaultPortrait.jpg" alt=""></a>
    </div>
</nav>

<!--中间-->
<div class="row">
    <!--侧边栏-->
    <ul class="navbar-nav bg-light text-center col-md-2">
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">高等数学</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn1" href="#">3.1</button>
                <button class="dropdown-item" id="btn2" href="#">3.2</button>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">计算机网络</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn3" href="#">4.1</button>
                <button class="dropdown-item" id="btn4" href="#">4.2</button>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">操作系统</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn5" href="#">4.5</button>
                <a class="dropdown-item" id="btn6" href="#">4.9</a>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">Java基础</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn7" href="#">4.5</button>
                <a class="dropdown-item" id="btn8" href="#">4.9</a>
            </div>
        </li>
    </ul>

    <!--主页面-->
    <div class="main col-10">
        <div class="main col-10 menu">
            <form id="form">
                <div id="tbody">

                </div>
            </form>
        </div>
    </div>
    <div class="box">
        <button type="button" id="grade"  class="bt">批改试卷</button>
    </div>

<!--页脚-->
<div class="footer bg-primary fixed-bottom text-center">
    <p class="text-white">版权所有© Copyright 1999-2021 爱思软件股份有限公司　　中国·青岛黄岛区嘉陵江路777号 西区公寓2号   版本V-0.0.1</p>
</div>
</div>
</body>
<script src="jquery/jquery-3.6.0.min.js"></script>
<script>
    //检测
    function checkboxnum(){
        let form = document.forms['form'];
        let i,j=0;
        for (i=0; i<form.length; i++){
            let e=form[i];
            if (e.checked && e.type=='checkbox' && e.name=='ids') {
                j++;
            }
        }
    }
    jQuery(function(){
        jQuery("#grade").click(function(){
                let form=jQuery("#form").serialize();
                jQuery.post("teacher/update",form,function (rst) {
                            alert(rst);
                        })
        });
    })

    jQuery(function () {
        jQuery("#btn1").click(function () {
            let form=jQuery("#form").serialize();<!-- 获取表单的数据-->
            jQuery.post("teacher/search2",form,function (rst) {
                let trs='';
                var m=new Array(rst.length);
                for(let i=0;i<rst.length;i++) {
                    let u = rst[i];
                    m[i] = "defaultCheck" + i;
                        if (u.type == 1) {
                            trs = `
                <input class="form-check-input1" name="ids" type="checkbox" value=" ${u.question}~3" ">
                <label class="zt" id="Question" name="Question">
                    ${u.question}
                </label>
                <br>
                <label class="zt" id="Right_Answer" name="Right_Answer">
                    &emsp;正确答案:${u.rightAnswer}
                </label>
                <br>
                <label class="zt" id="Right_Answer" name="Right_Answer">
                    &emsp;学生答案:${u.studentAnswer}
                </label>
                <br>`;
                            jQuery("#tbody").append(trs);
                        }
                        else {
                            let tm = u.question.split('A');
                            trs = `<input class="form-check-input1" name="ids" type="checkbox" value="${u.question}~3" id="defaultCheck1">
                <label class="zt" for="defaultCheck1">
                    ${tm[0]}
                </label>
                <br>
                <label class="zt" id="Right_Answer" name="Right_Answer">
                    &emsp;正确答案:${u.rightAnswer}
                </label>
                <br>
                <label class="zt" id="Right_Answer" name="Right_Answer">
                    &emsp;学生答案:${u.studentAnswer}
                </label>
                <br>`;
                            jQuery("#tbody").append(trs);
                        }
                }
            })
        })
    })
</script>
</html>
